package com.isoft.demo.service.impl;

import com.isoft.demo.common.ResponseData;
import com.isoft.demo.dao.EmployeeDao;
import com.isoft.demo.entity.Employee;
import com.isoft.demo.service.EmployeeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Resource
    private EmployeeDao dao;

    @Override
    public ResponseData searchSalary() {
        List<Employee> list = dao.searchSalary();
        ResponseData rs = new ResponseData();
        if(list != null){
            rs.setCode(0);
            rs.setMsg("ok");
            rs.setData(list);
        }else {
            rs.setCode(1);
            rs.setMsg("fail");
        }
        return rs;
    }

    @Override
    public ResponseData searchSalaryById(int eid) {
        List<Employee>list = dao.searchSalaryById(eid);
        ResponseData rs = new ResponseData();
        if(list != null){
            rs.setCode(0);
            rs.setMsg("ok");
            rs.setData(list);
        }else {
            rs.setCode(1);
            rs.setMsg("fail");
        }
        return rs;
    }

    @Override
    public ResponseData searchByEpost() {
        List<Employee>list = dao.searchByEpost();
        ResponseData rs = new ResponseData();
        if(list != null){
            rs.setCode(0);
            rs.setMsg("ok");
            rs.setData(list);
        }else {
            rs.setCode(1);
            rs.setMsg("fail");
        }
        return rs;
    }

    @Override
    public ResponseData searchByepost() {
        List<Employee>list = dao.searchByepost();
        ResponseData rs = new ResponseData();
        if(list != null){
            rs.setCode(0);
            rs.setMsg("ok");
            rs.setData(list);
        }else {
            rs.setCode(1);
            rs.setMsg("fail");
        }
        return rs;
    }
}
